package cn.com.b2office.struts2.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import cn.com.b2office.domain.MemberAddress;
import cn.com.b2office.domain.User;
import cn.com.b2office.service.MemberService;

import com.opensymphony.xwork2.ActionSupport;

public class ListAddressAction extends ActionSupport implements SessionAware {

	private static final long serialVersionUID = -1541396948094593415L;

	private Map session = null;

	private MemberService memberService = null;

	private List<MemberAddress> list = null;
	
	private Map<String, String> addressMap = null;

	public void setSession(Map session) {
		this.session = session;
	}

	public String execute() throws Exception {
		User user = (User) session.get("user");
		if (user == null)
			return "login";
		list = memberService.findAllAddress(user.getMemberId());
		addressMap = memberService.translateAddress(list);
		return SUCCESS;
	}

	public void setMemberService(MemberService memberService) {
		this.memberService = memberService;
	}

	public List<MemberAddress> getList() {
		return list;
	}

	public Map<String, String> getAddressMap() {
		return addressMap;
	}
	
	

}
